pp108 : format method(DateFormat)

format method(DateFormat)


Formats the date according to the display format set and the locale. If time zone is set on the DateFormat object or element, the value is formatted according to the time zone. If there is no time zone set, it takes the client time zone.

Syntax

dateFormatObj.format(value, meridiem)

Parameters

Parameter

Description

value

Required. The value to be formatted.

meridiem

Optional. AM/PM.


Return Value


Returns the formatted value.

Remarks

The value must be either JavaScript Date object or in the format YYYY-MM-DDTHH:MM:SS. If meridiem is passed, it is set at the end of the formatted value.

Example


The following example displays how this method is used.

importType("wcp.library.util.LocaleFormat");

importType("wcp.library.util.DateFormat");

var dateFormat = new DateFormat("longdate", "en-US", elmt);
dateFormat.format(new Date());

See Also


DateFormat, Locale